<?php
include_once 'Classes/DBClass.php';

class Login{

	function __construct(){

	}
	function isAuthenticated(){
		if(isset($_SESSION['isAuthenticated']))
		return $_SESSION['isAuthenticated'];
		else return false;
	}
	function Authenticate($username,$password){

		

		$mysql = new DBClass();

		$result = $mysql->Query("SELECT * FROM user WHERE (username='".$username."' AND password = '".$password."')");

		if($result){
			//Match
			$_SESSION["valid_id"] = $result[0][2];
			$_SESSION["valid_user"] = $username;
			$_SESSION["valid_time"] = time();
			$_SESSION['isAuthenticated'] = true;
			return true;
		}else{
			$_SESSION['isAuthenticated'] = false;
			return false;
		}




	}

}
?>
